{extend name="base" /}
{block name="content"}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>系统</span>
            <span class="icon-angle-right"></span>
            <span>用户管理</span>
            <span class="icon-angle-right"></span>
            <span>{$info ? '编辑' : '添加'}角色</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                            <tr>
                                <th colspan="2">{$info ? '编辑' : '添加'}角色</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="15%"><label for="name">角色名称<em>*</em></label></td>
                                <td><input type="text" class="u-ipt u-ipt-long" name="name" id="name" placeholder="请输入角色名称" value="{$info.name}" /></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="">权限设置</label></td>
                                <td>
                                    <div class="privilege">
                                        {foreach name="menus" key="key1" item="nav"}
                                            {if condition="$nav['status'] eq 0"}
                                            <div class="privilege-item lay-checked clearfix">
                                                <h2><input type="checkbox" class="select_item_all" lay-skin="primary" title="{$nav.name}" lay-filter="h2_privilege" /></h2>
                                                {if condition="$nav['name'] eq 'cms'"}
                                                {foreach name="nav['child']" key="key2" item="first"}
                                                    {foreach name="first['child']" key="key3" item="second"}
                                                    <dl class="clearfix"{if condition="(count($nav['child']) eq $key3+1) OR $key2 eq 1"} style="padding-bottom: 0; border-bottom: none;"{/if}>
                                                        <dt><h3 class="lay-checkbox"><input type="checkbox" class="select_item_all" lay-skin="primary" title="{$second.name}" lay-filter="h3_privilege" /></h3></dt>
                                                        {foreach name="second['child']" key="key4" item="third"}
                                                        <dd class="lay-checkbox"><input type="checkbox" name="authorities[]" lay-skin="primary" title="{$third.name}" value="{$third.url}"{if condition="$info && in_array($third['url'], $info['authorities'])"} checked{/if} /></dd>
                                                        {/foreach}
                                                    </dl>
                                                    {/foreach}
                                                {/foreach}
                                                {else/}
                                                {foreach name="nav['child']" key="key2" item="first"}
                                                    <dl class="clearfix"{if condition="count($nav['child']) eq $key2+1"} style="padding-bottom: 0; border-bottom: none;"{/if}>
                                                        <dt><h3 class="lay-checkbox"><input type="checkbox" class="select_item_all" lay-skin="primary" title="{$first.name}" lay-filter="h3_privilege" /></h3></dt>
                                                        {foreach name="first['child']" key="key3" item="second"}
                                                        <dd class="lay-checkbox"><input type="checkbox" name="authorities[]" lay-skin="primary" title="{$second.name}" value="{$second.url}"{if condition="$info && in_array($second['url'], $info['authorities'])"} checked{/if} /></dd>
                                                        {/foreach}
                                                    </dl>
                                                {/foreach}
                                                {/if}
                                            </div>
                                            {/if}
                                        {/foreach}
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="m-form-btn"><input type="hidden" name="id" value="{$info.id}"><button id="j_btn" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}